package LeetcodeTest_thirty_six;

//455. 分发饼干
import java.util.Arrays;

public class findContentChildren
{
    public static void main(String[] args)
    {
        int[] g={1,2,3};
        int[] s={1,2};
        System.out.println(Solution.findContentChildren(g,s));
    }
}
class Solution
{
    public static int findContentChildren(int[] g, int[] s)
    {
        Arrays.sort(g);
        Arrays.sort(s);
        int m=g.length;
        int n=s.length;
        int i,j,ans,index;
        index=ans=0;
        for(i=0;i<m;i++)
        {
            for(j=index;j<n;j++)
            {
                if(s[j]>=g[i])
                {
                    ans++;
                    index=j;
                    index++;
                    break;
                }
            }
        }
        return ans;
    }
}